<template>
  <div class="message-notice-control">
    <a-checkbox v-model:checked="val.isImmediate">
      进入此节点时给经办人发消息通知
    </a-checkbox>
    <template v-if="val.isImmediate">
      <a-select
        v-model:value="val.type"
        :options="options"
        placeholder="请选择"
      />
      <p class="tip">默认消息为"{创建人}+的+{表单名称}+需要您处理"</p>
    </template>
  </div>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue';

export default defineComponent({
  name: 'MessageNoticeControl',
  props: {
    value: {
      type: Object,
      default: () => ({}),
    },
    controls: {
      type: Object,
      default: () => ({}),
    },
    controlKey: {
      type: String,
      default: () => '',
    },
    options: {
      type: Object,
      default: () => ({}),
    },
  },
  setup(props, context) {
    const val = computed({
      get: () => props.value,
      set: (val) =>
        context.emit('updateValue', val, props.controlKey, props.controls),
    });

    return {
      val,
    };
  },
});
</script>

<style lang="less" scoped>
.message-notice-control {
  .ant-select {
    width: 100%;
    margin: 8px 0;
  }
  .tip {
    font-size: 12px;
    color: @rb-label-color;
  }
}
</style>
